#ifndef MOZHU_BMP
#define MOZHU_BMP

#include <stdint.h>
#include <fstream>
#include <vector>
#include <iostream>

#define BYTE uint8_t
#define WORD uint16_t
#define DWORD uint32_t
#define LONG uint32_t

struct BMPfileHead
{
    WORD filetype;          //文件种类，BMP固定为BM
    DWORD filesize;         //文件大小
    WORD reserveddata1;     //保留数据，目前没用
    WORD reserveddata2;     //保留数据，目前没用
    DWORD dataoffset;       //数据区偏移位，即为开头三个结构体的总大小
};

struct BMPinfoHead
{
    DWORD length;
    LONG  imgWidth;
    LONG imgHight;
    WORD planes;
    WORD bitcount;
    DWORD compression;
    DWORD imgsize;
    LONG XPelsPerMeter;
    LONG YPelsPerMeter;
    DWORD colorNum;
    DWORD importColorNum;
};

struct BMPRGBinfo
{
    BYTE blue;
    BYTE green;
    BYTE red;
    BYTE reserved;
};

enum IMG_TYPE
{
    BGR,
    BGRA,
    GREY
};


class IMG
{
public:
    bool loadBMP(std::string path);
    BMPfileHead imghead;
    BMPinfoHead imginfo;
    std::vector<BMPRGBinfo> colorpad;

    //套了三层，得解释一下，从里到外，分别是行，列，通道
    std::vector<std::vector<std::vector<uint8_t> > > data;

    IMG_TYPE type;
};

bool cvtcolor(IMG &src,IMG &dst);

bool drawhistogram(IMG &src,int number);


#endif